package org.farec.tcc.hibernate;

import org.farec.tcc.modelo.Cilindrada;
import org.farec.tcc.modelo.Cliente;
import org.farec.tcc.modelo.Fabricante;
import org.farec.tcc.modelo.Fornecedor;
import org.farec.tcc.modelo.Mecanico;
import org.farec.tcc.modelo.ModeloVeiculo;
import org.farec.tcc.modelo.OrdemServico;
import org.farec.tcc.modelo.Placa;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

@SuppressWarnings("deprecation")
public class HibernateUtil {
	
	private static SessionFactory factory;
	
	static {
		
		AnnotationConfiguration cfg = new AnnotationConfiguration();
		cfg.addAnnotatedClass(Cliente.class);
		cfg.addAnnotatedClass(Fornecedor.class);
		cfg.addAnnotatedClass(Mecanico.class);
		cfg.addAnnotatedClass(Cilindrada.class);
		cfg.addAnnotatedClass(Fabricante.class);
		cfg.addAnnotatedClass(ModeloVeiculo.class);
		cfg.addAnnotatedClass(Placa.class);
		cfg.addAnnotatedClass(OrdemServico.class);
		
		factory = cfg.buildSessionFactory();
		
	}
	
	public Session getSession()
	{
		return factory.openSession();
	}

}
